package com.atguigu.userprofile.mapper;

import com.atguigu.userprofile.bean.UserGroup;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import javax.ws.rs.DELETE;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zhangchen
 * @since 2021-05-04
 */


@Mapper
@DS("mysql")
public interface UserGroupMapper extends BaseMapper<UserGroup> {


    @Insert("${insertSQL}")
    @DS("clickhouse")
    public void insertBitmapSQL(@Param("insertSQL") String insertSQL);


    @Select("select  arrayJoin(bitmapToArray(us)) from user_group where user_group_id=#{id}   ")
    @DS("clickhouse")
    public List<String> selectBitmapToList(@Param("id") String id);

    @Select("select  arrayJoin(bitmapToArray( ${bitmapAndSQL}))    ")
    @DS("clickhouse")
    public List<String> selectBitmapToListBySQL(@Param("bitmapAndSQL") String bitmapAndSQL);


    @Select("${selectSQL}")
    @DS("clickhouse")
    public Integer selectUserGroupNum(@Param("selectSQL") String selectSQL);

    @Delete("alter table user_group delete where user_group_id = #{userGroupId}")
    @DS("clickhouse")
    public void deleteUserGroup(@Param("userGroupId") String userGroupId);

}
